<?php
header("content-type: text/plain");
ini_set("display_errors", true);

require_once 'autoload.php';


	$client = new Slash_Client_Client("http://saraha.jackpot.uk.net:82", "oarc", "ocset");
	$propreq = array("{http://theoarc.org.uk/events}keyholder", "{DAV:}getetag", "{urn:ietf:params:xml:ns:caldav}calendar-data");
	$results = $client->findEvents("/calendars/jackc", new DateTime("1 oct 2010 00:00"), new DateTime("30 oct 2010 00:00"), $propreq);
	foreach ($results as $href=>$result)
	{
		$props = $result["props"];
		$calobj = $result["caldata"];
		print "Href: $href\n";
		//print $calobj->toString();
		$events = $calobj->getEvents();
		foreach ($events as $event)
		{
			//There should be just one
			print "Start: " . $event->getDtStart()->format(DateTime::RFC822) . "\n";
			print "End: " . $event->getDtEnd()->format(DateTime::RFC822) . "\n";
			print "Description: " . $event->getDescription() . "\n";
			print "Summary: " . $event->getSummary() . "\n";
		}
		foreach ($props as $propName=>$prop)
		{
			print "Property " . $propName . ": " . $prop->textContent . "\n";
		}
		print "\n";
	}
	
	$results = $client->getEvent("/calendars/jackc/9fbe485d-f1d2-4b5b-94a5-0e9d3cee0804.ics", $propreq);
	foreach ($results as $href=>$result)
	{
		$props = $result["props"];
		$calobj = $result["caldata"];
		print "Href: $href\n";
		//print $calobj->toString();
		$events = $calobj->getEvents();
		foreach ($events as $event)
		{
			//There should be just one
			print "Start: " . $event->getDtStart()->format(DateTime::RFC822) . "\n";
			print "End: " . $event->getDtEnd()->format(DateTime::RFC822) . "\n";
			print "Description: " . $event->getDescription() . "\n";
			print "Summary: " . $event->getSummary() . "\n";
		}
		foreach ($props as $propName=>$prop)
		{
			print "Property " . $propName . ": " . $prop->textContent . "\n";
		}
		print "\n";
	}
	?> 